// part1:C11:ex11.38.cpp
// total of words. use unordered_map.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[])
{
  ifstream in(argv[1]);
  if (!in) {
    cout << "failed open input file!" << endl;
    exit(1);
  }

  unordered_map<string, size_t> word_count;
  string word;
  while (in >> word) {
    ++word_count[word];
  }

  for (const auto &w : word_count) {
    cout << w.first << " has : " << w.second << endl;
  }
  return 0;
}
